#include "stm32f0xx_hal.h"

#define DATA_HEAD  0x50
#define DATA_TAIL  0xDF

enum{
    STA_WAIT_HEAD,
    STA_WAIT_SUMA,
    STA_WAIT_TAIL,
};

typedef struct
{
	uint8_t* pRawBuf;
	uint8_t  status;
	uint16_t sizeRawBuf;
	uint16_t iRxRawBuf;
	uint16_t iRead;
	uint16_t dataLen;
	void (*pFun)(void);
}RxDcb_t;

typedef enum{
	ID_U5,
	ID_U4,
    ID_MAX
}ID_DATA_e;
#define DATA(a,i) (rxDcb[a].pRawBuf[(rxDcb[a].iRead+i)%rxDcb[a].sizeRawBuf])

extern RxDcb_t rxDcb[ID_MAX];

/*
解耦相关功能代码
RxDcb_t rxDcb[GET_MAX];
*/

// typedef struct
// {
//     uint32_t tickLastGet;
//     uint16_t iRead;
//     uint16_t dataLen;
//     uint8_t  status;
// }RxDcb_t;

// RxDcb_t rxDcb; 
//#define DATA(i) (Rx5RecData[(rxDcb.iRead+i)%RX5_SIZE])



/*
    DBG_CNT相关
*/
typedef enum{
    CMD10,
    CMD20,
    CMD21,
    CMD30,
    STATE1,
    STATE2_OK,
    STATE2_ERR,
    STATE3_OK,
    STATE3_ERR,
    CNT_MAX
}DBG_CNT_e;
extern uint16_t cnt_dbg[CNT_MAX];
#define DBG_INC(a)    (cnt_dbg[a]++)

void DbgCntShowAll(void);
void DbgCntClearAll(void);



void DataPreprocess(ID_DATA_e id);
void DataProcess(void);
void DataHandle_U5(void);
void DataHandle_U4(void);
